package middlewares

import (
	"github.com/kataras/iris/context"
	"github.com/kataras/iris"
	"blog/app/common"
)

const Authorization  = "Authorization"

func PermissionHandlerFunc() context.Handler  {
	return func(ctx iris.Context) {
		token := ctx.GetHeader(Authorization)
		if token != common.Token{
			ctx.JSON(common.NewCoderTip(common.NOPERMISSION))
			return
		}
		ctx.Next()
	}
}
